//
//  PersonPayFolderView.swift
//  XMYouPin
//
//  Created by 王宗成 on 2019/8/1.
//  Copyright © 2019 王宗成. All rights reserved.
//

import UIKit

class PersonPayFolderView: UIView {

    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */
    let bottomView: UIView = {
        
        let view:UIView = UIView()
        view.backgroundColor = .white
        return view
    }()
    
    private lazy var titleLabel : UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 18)
        label.text = "我的订单"
        label.textColor = UIColor.hexColor(hexadecimal: "#333333")
        label.textAlignment = NSTextAlignment.center
        
        return label
    }()
    
    let allButton: WZCButton = {
        
        let button:WZCButton = WZCButton(frame: CGRect(x: 0, y: 0, width: 10, height: 10))
        
        return button
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(self.bottomView)
        self.bottomView.snp.makeConstraints { (make) in
            
            make.left.equalTo(18)
            make.right.equalTo(-18)
            make.height.equalTo(128)
            make.bottom.equalTo(-10)
        }
        
        layoutIfNeeded()//强制刷新 获取snp 之后的frame
        
        self.bottomView.addSubview(self.titleLabel)
        self.titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(15)
            make.top.equalTo(15)
        }
  
        self.bottomView.layer.cornerRadius = 8;
        self.bottomView.layer.shadowColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 0.5).cgColor
        self.bottomView.layer.shadowOffset = CGSize(width: 0, height: 3);
        self.bottomView.layer.shadowOpacity = 0.5;
        self.bottomView.layer.shadowRadius = 6;
        
        self.bottomView.addSubview(self.allButton)
        self.allButton.snp.makeConstraints { (make) in
            make.right.equalTo(-15)
            make.height.equalTo(20)
            make.width.equalTo(70)
            make.centerY.equalTo(self.titleLabel.snp_centerY)
        }
        self.allButton.titleLabel.text = "全部订单"
        self.allButton.imgView.image = IMAGE("order_arrow")
    
        self.allButton.titleLabel.snp.remakeConstraints { (make) in
            
            make.left.equalTo(10)
            make.centerY.equalTo(self.allButton.snp_centerY)
        }
        
        self.allButton.imgView.snp.remakeConstraints { (make) in
            
            make.left.equalTo(self.allButton.titleLabel.snp_right).offset(5)
            make.centerY.equalTo(self.allButton.snp_centerY)
        }
       
        let width:CGFloat = self.bottomView.frame.size.width/4.0
        
        let titles:Array<String> = ["待付款","待收货","待评价","退款/售后"]
        let icons:Array<String> = ["mjyp_personal_icon_paid","mjyp_personal_icon_receipt","mjyp_personal_icon_appraisal","mjyp_personal_icon_return_goods"]
        
        for index in 0..<4 {
            
            let button:WZCButton = WZCButton(frame: CGRect(x: 0, y: 0, width: 10, height: 10))
            button.titleLabel.text = titles[index]
            button.imgView.image = IMAGE(icons[index])
            self.bottomView.addSubview(button)
            
            button.snp.makeConstraints { (make) in
                
                make.size.equalTo(CGSize(width: width, height: 50))
                make.left.equalTo(CGFloat(index)*width)
                make.bottom.equalTo(-12)
            }
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
